04. Viewing Modified Files

We just looked at the --oneline flag to show one commit per line. That's great for getting an overview of the repository. But what if we want to dig in a little to see what file or files were changed by a commit?

What file or files are modified?

If you look in the repository at commit a3dc99a, it has the message "Center content on page".

What file or files were changed in this commit?

SOLUTION: There's no way to know for sure

git log --stat Intro

The git log command has a flag that can be used to display the files that have been changed in the commit, as well as the number of lines that have been added or deleted. The flag is --stat ("stat" is short for "statistics"):

$ git log --stat

Run this command and check out what it displays.

_Two Terminal applications side-by-side. The left one shows the result of the `git log` command with all of the information while the right one shows the result of the `git log --stat` command which lists the files that were changed as well as the number of added/removed lines._

Two Terminal applications side-by-side. The left one shows the result of the git log command with all of the information while the right one shows the result of the git log --stat command which lists the files that were changed as well as the number of added/removed lines.

Nd016 WebND Ud123 Gitcourse BETAMOJITO L3 33 Git Log Vs Git Log --Stat Walkthru

How Many Files Were Modified?

Using what you've learned so far about git log and its flags, how many files were modified in the commit with the SHA 6f04ddd?

SOLUTION: 2 files

How Many Files Were Modified 2?

You did so well with the first one, so here's another! How many files were modified in the commit with the SHA 8d3ea36?

SOLUTION: 2 files

How Many Lines Were Modified?

Now it's time to look at the other info the --stat flag displays. How many lines of code were deleted in index.html in the commit with the SHA 8d3ea36?

SOLUTION: 4 lines

git log --stat Recap

To recap, the --stat flag is used to alter how git log displays information:

$ git log --stat

This command:

  • displays the file(s) that have been modified
  • displays the number of lines that have been added/removed
  • displays a summary line with the total number of modified files and lines that have been added/removed